<?php
class RatingsModel extends CI_Model {
	function cekRatingDominan($genreid, $userid){
//		$sql = "select MOVIEID from ratings where MOVIEID = 
//				ANY (select MOVIEID from movies where movies.GENREID = $genreid) and MOVIEID <>
//				any (select MOVIEID from rekomendasi where rekomendasi.USERID = $userid) order by rank desc";
		$sql = "select MOVIEID from ratings where MOVIEID in 
				(select MOVIEID from movies where movies.GENREID = $genreid) and MOVIEID not in
				(select MOVIEID from rekomendasi where rekomendasi.USERID = $userid) order by rank desc";
		$data = $this->db->query($sql);
		return $data;		
	}
	
//	function cekRatingDominanAwal($genreid){
//		$sql = "select MOVIEID from ratings where MOVIEID = 
//				ANY (select MOVIEID from movies where movies.GENREID = $genreid) order by rank desc";
//		$data = $this->db->query($sql);
//		return $data;		
//	}
	
	function cekRating($genre, $userid){
//		$sql = "select MOVIEID from ratings where MOVIEID = 
//				ANY (select MOVIEID from genres where genres.GENRE = '$genre') and MOVIEID <>
//				any (select MOVIEID from rekomendasi where rekomendasi.USERID = $userid)order by rank desc";
		$sql = "select MOVIEID from ratings where MOVIEID in 
				(select MOVIEID from genres where genres.GENRE = '$genre') and MOVIEID not in
				(select MOVIEID from rekomendasi where rekomendasi.USERID = $userid)order by rank desc";
		$data = $this->db->query($sql);
		return $data;		
	}
	
//	function cekRatingAwal($genre){
//		$sql = "select MOVIEID from ratings where MOVIEID = 
//				ANY (select MOVIEID from genres where genres.GENRE = '$genre') order by rank desc";
//		$data = $this->db->query($sql);
//		return $data;		
//	}
}
?>